﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace WPFClient.Codes
{
    /// <summary>
    /// 滚筒线通信协议
    /// </summary>
    public class RollerPLCProtocolMessage
    {
        /// <summary>
        /// 帧头：2字节
        /// </summary>
        public ushort FrameHeader { get; set; }

        /// <summary>
        /// 设备号：2字节
        /// </summary>
        public ushort DeviceId { get; set; }

        /// <summary>
        /// 任务号：4字节（范围：1-100,000,000）
        /// </summary>
        public long TaskId { get; set; }

        /// <summary>
        /// 备用：2字节
        /// </summary>
        public ushort Reserved { get; set; }

        /// <summary>
        /// 协议尾：3字节（固定0xFFFFFF）
        /// 注：实际存储为4字节，但协议中只有3字节
        /// </summary>
        public uint ProtocolTail { get; set; }

        /// <summary>
        /// 更新时间
        /// </summary>
        public DateTime UpdateTime { get; set; }

        /// <summary>
        /// 二维码
        /// </summary>
        public string QrCode { get; set; }  

        /// <summary>
        /// 测量尺寸
        /// </summary>
        public float MeasuredDimensions{get;set;}

        /// <summary>
        /// 体积重量
        /// </summary>
        public float VolumetricWeight { get; set;}

        /// <summary>
        /// 判断协议尾是否正确（检查低24位是否为0xFFFFFF）
        /// </summary>
        public bool IsValidTail => (ProtocolTail & 0xFFFFFF) == 0xFFFFFF;
    }
}
